﻿using System;
using System.Configuration;
using System.Web.Configuration;

namespace ALinq.BBS.Common
{
    public class DataBaseSection : ConfigurationSection
    {
        [ConfigurationProperty("defaultProvider")]
        public string DefaultProvider
        {
            get { return (string) base["defaultProvider"]; }
        }

        [ConfigurationProperty("providers")]
        public ProviderSettingsCollection Providers
        {
            get { return (ProviderSettingsCollection) base["providers"]; }
        }

        public static DataBaseSection CreateInstance(Configuration config)
        {
            DataBaseSection section = WebConfigurationManager.GetSection("koloBBS/dataBase") as DataBaseSection;
            //DataBaseSection section = config.GetSection("koloBBS/dataBase") as DataBaseSection;
            if(section == null)
                throw new Exception("DataBase没有配置好。");
            return section;
        }
    }
}